package cn.iocoder.yudao.framework.common.util.file;

import java.util.Arrays;
import java.util.List;

public class FileUtils {

    /**
     * 支持的图片文件类型
     */
    public static final List<String> SUPPORTED_IMAGE_TYPES = Arrays.asList(".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp");

    /**
     * 获取文件扩展名
     */
    public static String getFileExtension(String filename) {
        if (filename == null || filename.isEmpty()) {
            return "";
        }
        int lastDotIndex = filename.lastIndexOf('.');
        return lastDotIndex == -1 ? "" : filename.substring(lastDotIndex).toLowerCase();
    }

    /**
     * 判断是否为图片文件
     */
    public static Boolean isImageFile(String extension) {
        return SUPPORTED_IMAGE_TYPES.contains(extension);
    }

}
